package com.ebt.m.customer.constant;

import com.ebt.m.R;
import com.ebt.m.customer.view.RecorderWrapper;
import com.ebt.m.utils.ConfigData;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class CustomerConstant {


    public static class SpreadAnim{
        public static final String SEX = "SEX";
        public static final String URL_AVATAR = "URL_AVATAR";

    }
    public static class Url{
        public static final String INSURANCE_BASE_URL = "http://mzyj.test.e-baotong.cn/policy/";
    }

    public static class InteractionType{
        public static final int DEFAULT = -1;    //新建客户
        public static final int CUSTOMER_CREATE = 0;    //新建客户
        public static final int INSURANCE_CREATE = 1;   //新建保单
        public static final int INSURANCE_EDIT = 2;     //编辑保单
        public static final int PROPOSAL_SEND = 3;      //发送计划书
        public static final int PROPOSAL_READ = 4;      //查看计划书
        public static final int NOTE_CREATE = 5;        //创建笔记
        public static final int NOTE_EDIT = 6;          //修改笔记
        public static final int PHONE_CALL = 7;         //拨打电话

        public static final String TEXT_CUSTOMER_CREATE = "新建客户";
        public static final String TEXT_INSURANCE_CREATE = "新建保单";
        public static final String TEXT_INSURANCE_EDIT = "编辑保单";
        public static final String TEXT_PROPOSAL_SEND = "发送计划书";
        public static final String TEXT_PROPOSAL_READ = "查看计划书";
        public static final String TEXT_NOTE_CREATE = "创建笔记";
        public static final String TEXT_NOTE_EDIT = "修改笔记";
        public static final String TEXT_PHONE_CALL = "拨打电话";
        public static final String TEXT_DEFAULT = "";

        public static final HashMap<Integer, String> map;
        static{
            map = new HashMap<>();
            map.put(CUSTOMER_CREATE, TEXT_CUSTOMER_CREATE);
            map.put(INSURANCE_CREATE, TEXT_INSURANCE_CREATE);
            map.put(INSURANCE_EDIT, TEXT_INSURANCE_EDIT);
            map.put(PROPOSAL_SEND, TEXT_PROPOSAL_SEND);
            map.put(PROPOSAL_READ, TEXT_PROPOSAL_READ);
            map.put(NOTE_CREATE, TEXT_NOTE_CREATE);
            map.put(NOTE_EDIT, TEXT_NOTE_EDIT);
            map.put(PHONE_CALL, TEXT_PHONE_CALL);
            map.put(DEFAULT, TEXT_DEFAULT);
        }

        public static String getShowText(Integer integer){
            if (integer == null || !map.containsKey(integer)){
                return map.get(DEFAULT);
            }
            return map.get(integer);
        }
    }

    public static class CustomerImportMode{
        public static final boolean FOR_NET = true;
    }
    public static class CustomerActive{
        public static final String VIEW_PAGER_INDEX = "VIEW_PAGER_INDEX";
        public static final int VIEW_PAGER_INDEX_ALL = 0;
        public static final int VIEW_PAGER_INDEX_PROPOSAL = 1;
        public static final int VIEW_PAGER_INDEX_NOTE = 2;
        public static final int VIEW_PAGER_INDEX_PHONE = 3;
        public static final String[] TITLES = new String[]{"最近30天活动客户","本月计划书","本月笔记","打电话给客户"};
    }

    public static class CustomerNote{
        public static final String TABLE_NAME = "customer_note";
        public static final String CHANGE_STATUES = "ChangeStatus";

        public static final String UUID = "uuid";
        public static final String MODE = "NOTE_MODE";
        public static final String MODE_ADD = "mode_add";
        public static final String MODE_EDIT = "mode_edit";
        public static final String MODE_SHOW = "mode_show";
    }

    public static class CustomerAll{
        public static final String VIEW_PAGER_INDEX = "VIEW_PAGER_INDEX";

        public static final int VIEW_PAGER_INDEX_PROFILE = 0;
        public static final int VIEW_PAGER_INDEX_INSURANCE = 1;
        public static final int VIEW_PAGER_INDEX_PROPOSAL = 2;
        public static final int VIEW_PAGER_INDEX_NOTE = 3;
        public static final int VIEW_PAGER_INDEX_ATTACHMENT = 4;
        public static final int VIEW_PAGER_INDEX_INTERACTION = 5;
    }

	public static class SharedElement {
        public static final boolean ENABLE = false;
        public static final String INDEX = "INDEX";
        public static final String FROM = "FROM";
		public static final String FROM_CUSTOMER_ALL = "FROM_CUSTOMER_ALL";
        public static final boolean SHOW_REVEAL_ANIMATION = false;
	}

    public static class Delay {
        //单位毫秒
        public static final long RIPPLE_DELAY = 300;
        public static final long FRAGMENT_UPDATE_DELAY = 300;
    }

    public static class CustomerFromContact{
        public static final String TABLE_NAME = "customer_from_contact";
        public static final String UUID = "uuid";
        public static final String CUSTOMER_NAME = "customerName";
        public static final String CUSTOMER_UUID = "customerUuid";
        public static final String CONTACT_NAME = "contactName";
        public static final String CONTACT_RAW_ID = "contactRawId";
        public static final String CONTACT_SORT_KEY = "contactSortkey";
        public static final String CONTACT_IGNORE = "contactIgnore";
        public static final String CONTACT_IGNORE_VALUE = "1";
        public static final String CHANGE_STATUES = "ChangeStatus";
        public static final String IDENTITY = "identity";
    }

    public static class CustomerGet{
        public static final int GET_CONTACT_MAX = 5000;
        public static final String FIRST_READ_CONTACT = "FIRST_READ_CONTACT";
        public static final String CAN_READ_CONTACT = "CAN_READ_CONTACT";
    }

    public static class Customer{
        public static final String TABLE_NAME = "customer";
        public static final String IDENTITY = "identity";
        public static final String UUID = "uuid";
        public static final String NAME = "name";
        public static final String NAMEPREFIX = "namePrefix";
        public static final String SORT_KEY_STRING = "sortKeyString";
        public static final String SORT_KEY_CHAR = "sortKeyChar";
        public static final String IMPORT_CONTACT = "importContact";
        public static final String LAST_ACTIVE_TIME_2 = "lastActiveTime2";
        public static final String CHANGE_STATUES = "ChangeStatus";
        public static final String CREATE_TIME = "createTime";
        public static final String IS_MARRAGE = "isMarrage";
        public static final String CAREER_CATEGORY = "careerCategory";
        public static final String BIRTHDAY = "birthday";
        public static final String SEX = "sex";
        public static final String STATE = "state";
    }

    public static class CustomerSimple{
        public static final String TABLE_NAME = "customer_simple";

        public static final String COLUMN_ID = "customerId";
        public static final String COLUMN_NAME = "name";
        public static final String COLUMN_SEX = "sex";
        public static final String COLUMN_TAG = "tag";
        public static final String COLUMN_NAME_PREFIX = "namePrefix";
        public static final String COLUMN_PORTRAIT_PATH = "portraitPath";
    }

    public static class StringPromptRes{
        public static class Net{
            public static final int NET_NOT_AVAILABLE = R.string.network_fail;
        }
    }

    public static class EducationGrade{

        public static final int EDU_GRADE_UNKNOWN = 0;
        public static final int EDU_GRADE_SENIOR_1 = 1;
        public static final int EDU_GRADE_SENIOR_2 = 2;
        public static final int EDU_GRADE_BACHELOR = 3;
        public static final int EDU_GRADE_MASTER = 4;
        public static final int EDU_GRADE_PHD = 5;

        public static final String EDU_GRADE_UNKNOWN_TEXT = "未知";
        public static final String EDU_GRADE_SENIOR_1_TEXT = "中专及以下";
        public static final String EDU_GRADE_SENIOR_2_TEXT = "大专";
        public static final String EDU_GRADE_BACHELOR_TEXT = "本科";
        public static final String EDU_GRADE_MASTER_TEXT = "硕士";
        public static final String EDU_GRADE_PHD_TEXT = "博士";

        public static final HashMap<Integer, String> map;
        public static final HashSet<String> set;
        static{
            map = new HashMap<>();
            map.put(EDU_GRADE_UNKNOWN, EDU_GRADE_UNKNOWN_TEXT);
            map.put(EDU_GRADE_SENIOR_1, EDU_GRADE_SENIOR_1_TEXT);
            map.put(EDU_GRADE_SENIOR_2, EDU_GRADE_SENIOR_2_TEXT);
            map.put(EDU_GRADE_BACHELOR, EDU_GRADE_BACHELOR_TEXT);
            map.put(EDU_GRADE_MASTER, EDU_GRADE_MASTER_TEXT);
            map.put(EDU_GRADE_PHD, EDU_GRADE_PHD_TEXT);

            set = new HashSet<>();
            set.add(String.valueOf(EDU_GRADE_UNKNOWN));
            set.add(String.valueOf(EDU_GRADE_SENIOR_1));
            set.add(String.valueOf(EDU_GRADE_SENIOR_2));
            set.add(String.valueOf(EDU_GRADE_BACHELOR));
            set.add(String.valueOf(EDU_GRADE_MASTER));
            set.add(String.valueOf(EDU_GRADE_PHD));
        }

        public static String getShowText(Integer integer){
            if (integer == null){
                return map.get(EDU_GRADE_UNKNOWN);
            }
            if (!map.containsKey(integer)){
                return map.get(EDU_GRADE_UNKNOWN);
            }
            return map.get(integer);
        }

        public static int getEduInt(String career){
            Set<Map.Entry<Integer, String>> set = map.entrySet();
            Iterator<Map.Entry<Integer, String>> it = set.iterator();
            while (it.hasNext()){
                Map.Entry<Integer, String> item = it.next();
                if(item.getValue().equals(career)){
                    return item.getKey();
                }
            }
            return 0;
        }

        public static boolean isEduLegal(String edu){
            if (set.contains(edu)){
                return true;
            }
            return false;
        }
    }

    public static class CustomerTag{

//        0:普通客户、1:准客户、2:保单客户
        public static final int TAG_0 = 0;
        public static final int TAG_1 = 1;
        public static final int TAG_2 = 2;

        public static final String TAG_TEXT_0 = "普通客户";
        public static final String TAG_TEXT_1 = "准客户";
        public static final String TAG_TEXT_2 = "保单客户";

        public static final HashMap<Integer, String> map;
        static{
            map = new HashMap<>();
            map.put(TAG_0, TAG_TEXT_0);
            map.put(TAG_1, TAG_TEXT_1);
            map.put(TAG_2, TAG_TEXT_2);
        }

        public static String getShowText(Integer integer){
            if (integer == null){
                return map.get(TAG_0);
            }
            if (!map.containsKey(integer)){
                return map.get(TAG_0);
            }
            return map.get(integer);
        }

        public static int getShowBackgroundRes(Integer integer){
            if (integer == null || integer == 0){
                return R.drawable.bg_trans_rect_hollow;
            }
            if (integer == TAG_1){
                return R.drawable.bg_blue_rect_solid;
            }
            if (integer == TAG_2){
                return R.drawable.bg_orange_rect_solid;
            }
            return R.drawable.bg_trans_rect_hollow;
        }
    }

    public static class CustomerLevel{

        public static final int LEVEL_0 = 0;
        public static final int LEVEL_1 = 1;
        public static final int LEVEL_2 = 2;
        public static final int LEVEL_3 = 3;
        public static final int LEVEL_4 = 4;

        public static final String LEVEL_TEXT_0 = "A";
        public static final String LEVEL_TEXT_1 = "B";
        public static final String LEVEL_TEXT_2 = "C";
        public static final String LEVEL_TEXT_3 = "D";
        public static final String LEVEL_TEXT_4 = "E";

        public static final HashMap<Integer, String> map;
        static{
            map = new HashMap<>();
            map.put(LEVEL_0, LEVEL_TEXT_0);
            map.put(LEVEL_1, LEVEL_TEXT_1);
            map.put(LEVEL_2, LEVEL_TEXT_2);
            map.put(LEVEL_3, LEVEL_TEXT_3);
            map.put(LEVEL_4, LEVEL_TEXT_4);
        }

        public static String getShowText(Integer integer){
            if (integer == null){
                return map.get(LEVEL_0);
            }
            if (!map.containsKey(integer)){
                return map.get(LEVEL_0);
            }
            return map.get(integer);
        }

        public static int getLevelInt(String level){
            Set<Map.Entry<Integer, String>> set = map.entrySet();
            Iterator<Map.Entry<Integer, String>> it = set.iterator();
            while (it.hasNext()){
                Map.Entry<Integer, String> item = it.next();
                if(item.getValue().equals(level)){
                    return item.getKey();
                }
            }
            return 0;
        }
    }

    public static class CareerCategory{

        public static final int CAREER_CATEGORY_UNKNOWN = 0;
        public static final int CAREER_CATEGORY_1 = 0;
        public static final int CAREER_CATEGORY_2 = 1;
        public static final int CAREER_CATEGORY_3 = 2;
        public static final int CAREER_CATEGORY_4 = 3;
        public static final int CAREER_CATEGORY_5 = 4;
        public static final int CAREER_CATEGORY_6 = 5;

        public static final String CAREER_CATEGORY_UNKNOWN_TEXT = "一类职业";
        public static final String CAREER_CATEGORY_TEXT_1 = "一类职业";
        public static final String CAREER_CATEGORY_TEXT_2 = "二类职业";
        public static final String CAREER_CATEGORY_TEXT_3 = "三类职业";
        public static final String CAREER_CATEGORY_TEXT_4 = "四类职业";
        public static final String CAREER_CATEGORY_TEXT_5 = "五类职业";
        public static final String CAREER_CATEGORY_TEXT_6 = "六类职业";

        public static final HashMap<Integer, String> map;
        static{
            map = new HashMap<>();
            map.put(CAREER_CATEGORY_UNKNOWN, CAREER_CATEGORY_UNKNOWN_TEXT);
            map.put(CAREER_CATEGORY_1, CAREER_CATEGORY_TEXT_1);
            map.put(CAREER_CATEGORY_2, CAREER_CATEGORY_TEXT_2);
            map.put(CAREER_CATEGORY_3, CAREER_CATEGORY_TEXT_3);
            map.put(CAREER_CATEGORY_4, CAREER_CATEGORY_TEXT_4);
            map.put(CAREER_CATEGORY_5, CAREER_CATEGORY_TEXT_5);
            map.put(CAREER_CATEGORY_6, CAREER_CATEGORY_TEXT_6);
        }

        public static String getShowText(Integer integer){
            if (integer == null){
                return map.get(CAREER_CATEGORY_UNKNOWN);
            }
            if (!map.containsKey(integer)){
                return map.get(CAREER_CATEGORY_UNKNOWN);
            }
            return map.get(integer);
        }

        public static int getCareerInt(String career){
            Set<Map.Entry<Integer, String>> set = map.entrySet();
            Iterator<Map.Entry<Integer, String>> it = set.iterator();
            while (it.hasNext()){
                Map.Entry<Integer, String> item = it.next();
                if(item.getValue().equals(career)){
                    return item.getKey();
                }
            }
            return 0;
        }
    }

    public static class UI{
        public static final int ACTION_BUTTON_ROTATION = 135;
    }

    public static class Sort{
        public static final char[] CHARS_ALPHA = {'#','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
        public static final int CHARS_ALPHA_SIZE = 27;
    }

    public static class CustomerContact{
        public static final int TYPE_PHONE = 1;
        public static final int TYPE_EMAIL = 2;
        public static final int TYPE_IM = 3;
    }

    public static class Profile{
        public static final String SEX_WOMAN = "女";
        public static final String SEX_MAN = "男";
        public static final String MARRIAGE_YES = "已婚";
        public static final String MARRIAGE_NO = "未婚";
    }

    public static class CustomerImport{
        public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id";
    }

    public static class CustomerDetail{
        public static final String CHOOSE = "customer_detail_choose";
    }

    public static class Attachment{
        public static final String DIR_PATH = ConfigData.EBT_CUSTOMER_ATTACHMENT;
        public static final String ATTA_NAME_SEPARATOR = "_";
        public static final int SIZE_1_M = 1000 * 1000;
        public static final int SIZE_10_M = 10 * SIZE_1_M;
        public static final int SIZE_20_M = 20 * SIZE_1_M;
    }

    public static class Recorder{
        public static final String DIR_PATH = RecorderWrapper.RECORDER_DIR;
        public static final String DOWNLOAD_FLAG_SUCCESS = "SUCCESS";
        public static final String DOWNLOAD_FLAG_FAIL = "FAIL";
    }

	public static final String CUSTOMER_UUID = "customerUuid";
	public static final String CUSTOMER_DETAIL_MODE = "customer_detail";
	public static final String CUSTOMER_DETAIL_MODE_ADD = "customer_detail_add";
	public static final String CUSTOMER_DETAIL_MODE_EDIT = "customer_detail_edit";
    public static final String CUSTOMER_DETAIL_ENTITY = "CUSTOMER_DETAIL_ENTITY";
    public static final String CUSTOMER_DETAIL_NOTE_DEFAULT_VALUE = "customer_detail_note_default_value";

    public static final String CUSTOMER_DATA= "customer_data";

	public static final String SERVICE_FETCH_MODE = "mode";
	public static final int SERVICE_FETCH_CUSTOMER_IMPORT_OTHER = 2;
	public static final String SERVICE_FETCH_CUSTOMER_IMPORT_OTHER_KEY = "CONTACTS_WITH_CUUID";

    //customer table
	public static final String TABLE_CUSTOMER_NOTE = "customer_note";
	public static final String COLUMN_NOTE_LAST_UPDATE_TIME = "lastUpdateTime";

    public static final String TABLE_CUSTOMER_INTERACTION = "customer_interaction";

	public static final String TABLE_CUSTOMER = "customer";
	public static final String COLUMN_CUSTOMER_SORT_KEY_STRING = "sortKeyString";
    public static final String COLUMN_CUSTOMER_CREATE_TIME = "createTime";

    public static final int COLUMN_CUSTOMER_STATE_IMPORT = 1;

	public static final String TABLE_CUSTOMER_ATTACHMENT = "customer_attachment";
	
	public static final String TABLE_CUSTOMER_CONTACT = "customer_contact";
	public static final String COLUMN_CUSTOMER_CONTACT_UUID = "uuid";
	public static final String COLUMN_CUSTOMER_CONTACT_CTYPE = "ctype";
	public static final String COLUMN_CUSTOMER_CONTACT_CLASSIFICATION = "classification";
	public static final String COLUMN_CUSTOMER_CONTACT_CVALUE = "cvalue";
	public static final String COLUMN_CUSTOMER_CONTACT_CUSTOMERUUID = "customerUUId";
	public static final String COLUMN_CUSTOMER_CONTACT_ISDEFAULT = "isDefault";
	public static final String COLUMN_CUSTOMER_CONTACT_DESCRIPTION = "description";//“家庭”、“手机”、“公司”、“其它”、“自定义”
	public static final String COLUMN_CUSTOMER_CONTACT_CHANGESTATUS = "ChangeStatus";
	
	public static final String COLUMN_CHANGE_STATUS = "ChangeStatus";// 状态  
	public static final int COLUMN_CHANGE_STATUS_DEFAULT = 0;// 状态  0 默认值
	public static final int COLUMN_CHANGE_STATUS_ADD = 1;// 状态  1 增加
	public static final int COLUMN_CHANGE_STATUS_EDIT = 2;// 状态  2 修改
	public static final int COLUMN_CHANGE_STATUS_DELETE = 3;// 状态  3 删除

	public static final String COLUMN_CHANGE_STATUS_NOT_DELETE = COLUMN_CHANGE_STATUS + "<>" + COLUMN_CHANGE_STATUS_DELETE;
	
	public static final int CUSTOMER_CONTACT_TYPE_PHONE = 1;
	public static final int CUSTOMER_CONTACT_TYPE_EMAIL = 2;
	public static final int CUSTOMER_CONTACT_TYPE_IM = 3;
	
	public static final int CUSTOMER_ANIMATION_OPTION_MENU_DURATION = 150;
	
	//获客table
	public static final String TABLE_CUSTOMER_GET = "customer_get";
	public static final String COLUMN_CUSTOMER_GET_UUID = "uuid";
	public static final String COLUMN_CUSTOMER_GET_THRESHOLD = "thresholdTime";
	public static final String COLUMN_CUSTOMER_GET_TYPE = "type";
	public static final String COLUMN_CUSTOMER_GET_RAW_CONTACT_ID = "rawContactId";
	
	public static final String CUSTOMER_GET_TYPE_THRESHOLD = "0";
	public static final String CUSTOMER_GET_TYPE_IGNORE = "1";
	public static final String CUSTOMER_GET_TYPE_GET = "2";
	public static final int CUSTOMER_GET_IGNORE = 1;

	public static final String COLUMN_CUSTOMER_ATTACHMENT_TIME = "lastUpdateTime";
	/**
	 * 文件分隔符
	 */
	public static final String CUSTOMER_FILE_DIVIDER = "&&&";
	
}